home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-12 | 7.4 KB | 215 lines | [TEXT/MMCC] |
- /*********************************************************************
-
- Simple Sample.h
-
- This is the header file for the QuickDraw GX aware sample,
- "Simple Sample GX."
-
- Additional info can be found in the related develop #19 article,
- "Adding QuickDraw GX Printing to QuickDraw Applications."
-
- Dave Hersey, Apple Developer Technical Support.
-
- ——————— Edit Trail ———————
-
- spawned: 1/22/94 - dmh
- cleaned up for 2nd draft of develop article: 3/10/94 - dmh
- cleaned up for final: 4/14/94 - dmh
- universalized: 8/24/94 - dmh
- changed for new GX interfaces: 7/11/95 - dmh
-
- *********************************************************************/
-
- //#include <stdio.h> // Regular interface files.
- #include <AppleEvents.h>
- #include <Desk.h>
- #include <Events.h>
- #include <Files.h>
- #include <Fonts.h>
- #include <GestaltEqu.h>
- #include <Memory.h>
- #include <Packages.h>
- #include <Quickdraw.h>
- #include <Resources.h>
- #include <StandardFile.h>
- #include <ToolUtils.h>
- #include <Types.h>
- #include <Windows.h>
-
- #include <GXGraphics.h> // QuickDraw GX interface files.
- #include <GXEnvironment.h>
- #include <GXPrinting.h>
- #include <GXExceptions.h> // some GX headers called this exceptions.h, you may need to rename the file
- // in your GX folder from exceptions.h to GXExceptions.h
-
- #define kOSEvent app4Evt /* Event used by MultiFinder */
- #define kSuspendResumeMessage 1 /* High byte of suspend/resume event message */
- #define kResumeMask 1 /* Bit of message field for resume vs. suspend */
-
- #define r_About 128 /* Our app's "About…" alert ID. */
- #define r_BadConfig 130 /* Our app's "Bad configuration…" alert ID. */
- #define r_documentPict 128 /* Our PICT's resource ID. */
- #define r_documentBitmap 128 /* Our ICON's resource ID. */
-
- #define kMyDocCreator 'SSam' /* Our app's creator. */
- #define kMyDocType 'aDoc' /* Our document file type. */
- #define kMyPageCountType 'Pgs?' /* Our page count resource type. */
- #define kMyPageCountID 2000 /* Our page count resource ID. */
- #define kMyPrintRecType 'THPR' /* Our print record resource type. */
- #define kMyPrintRecID 1000 /* Our print record resource ID. */
- #define kMyJobType 'FJOB' /* Our gxJob resource type. */
- #define kMyJobID 1000 /* Our gxJob resource ID. */
- #define kMyFormatInfoType 'FLST' /* Our format list collection item tag. */
- #define kMyFormatInfoTagID 1000 /* Our format list collection item ID. */
-
- #define kGraphicsHeapSize ((long) 300 * 1024)
- #define kDefaultTitle ((char *) "\pUntitled Document")
-
- // Various PicComments:
-
- #define PostScriptBegin 190
- #define PostScriptEnd 191
- #define PostScriptHandle 192
-
-
- /*
- MyDocumentRec - This structure contains information that we store
- about each document we open or create. We store a handle to one
- of these beasties in each window's refCon field. Note that the
- MyDocumentRec data type in this example is simplified to handle a
- maximum of 20 pages.
- */
-
- #define kMaxPages 20
-
- typedef struct MyDocumentRec {
- THPrint documentPrintHdl; // Print Record bound to this document.
- gxJob documentJob; // Job bound to this document.
- gxFormat pageFormat[kMaxPages]; // format for each page. If nil, we use
- // the job format.
-
- long numPages; // Number of pages in this document.
- long curPage; // The current page that we're looking at.
- FSSpec documentFSSpec; // The file specification for this document.
- Str31 documentTitle; // The title of this document (such
- // as "Untitled").
- WindowPtr documentWindow; // The window for this document.
- } MyDocumentRec, *MyDocumentPtr;
-
-
- typedef struct MySpoolDataRec {
- gxRectangle pageArea; // Page rectangle.
- gxViewPort printViewPort; // ViewPort we're printing with.
- } MySpoolDataRec, *MySpoolDataPtr;
-
-
- // globals from main.c:
-
- extern short gAppResRefNum;
- extern Rect gWindowRect;
- extern Boolean gQuitAfterPrinting, gQuitting, gSystemSevenIsPresent;
- extern Boolean gGXIsPresent, gInPrintDialog;
- extern long gSleep;
- extern gxGraphicsClient gClient;
-
- // Prototypes: //
-
- // main.c:
-
- void MyInitialize(void);
- void MyCheckConfig(void);
- void MyInitGXIfPresent(void);
- void MyCleanUpGXIfPresent(void);
- OSErr MyPrintingEventOverride(EventRecord *anEvent, Boolean filterEvent);
- void main(void);
-
- // events.c
-
- void MyEventLoop(void);
- void MyDoEvent(EventRecord *theEvent);
- void MyDoAEInstallation(void);
- pascal OSErr MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- OSErr MyCheckAEParams(AppleEvent *theAppleEvent);
-
- // file.c
-
- OSErr MyLoadDocument(MyDocumentPtr whichDocument);
- OSErr MyFSLoadDocument(MyDocumentPtr destDocument, FSSpec *docFSSpec, Boolean forPrinting);
- Boolean MyIsWindowAlreadyOpen(FSSpec *whichFSSpec);
- OSErr MySaveDocument(MyDocumentPtr myDocument, Boolean doingSaveAs);
- OSErr MySavePageCount(MyDocumentPtr whichDocument, short resRefNum);
- long MyLoadPageCount(short resRefNum);
- OSErr MySaveFormatRefs(MyDocumentPtr whichDocument);
- OSErr MyCreateFormatIndexList(MyDocumentPtr whichDocument, Handle *theFormatIdxList);
- OSErr MyAdjustFormats(MyDocumentPtr whichDocument);
- OSErr MySavePrintInfo(MyDocumentPtr whichDocument, short resRefNum);
- OSErr MyLoadPrintInfo(MyDocumentPtr whichDocument, short resRefNum);
-
- // menus & windows.c:
-
- OSErr MyCreateDocument(char *title, MyDocumentPtr *createdDocument);
- void MyDisposeDocument(MyDocumentPtr whichDocument);
- OSErr MyInsertPage(MyDocumentPtr whichDocument, long *whichPage);
- void MyDisposePage(MyDocumentPtr whichDocument, long whichPage);
- void MyUpdateWindow(WindowPtr whichWindow);
- void MyDrawContents(WindowPtr whichWindow);
- void MyDrawPicComments(void);
- void MySendPostScript(Str255 thePostScript);
- void MyAdjustMenus(void);
- void MyAdjustMenusForPrintDialogs(Boolean dialogGoingUp);
- void MyDoMenuCommand(long menuResult);
- void MyConvertMenuItem(short *menuID, short *menuItem);
- MyDocumentPtr MyGetDocPtr(WindowPtr whichWindow);
-
- // printing.c:
-
- OSErr MyPrintDocument(MyDocumentPtr whichDocument);
- OSErr MyPrintOneCopy(MyDocumentPtr whichDocument);
- OSErr MyQDPrintLoop(MyDocumentPtr whichDocument);
- OSErr MyGXPrintLoop(MyDocumentPtr whichDocument);
- OSErr MyPrintAShape(gxShape currentShape, long refCon);
- Boolean MyDoPageSetup(MyDocumentPtr whichDocument);
- Boolean MyDoCustomPageSetup(MyDocumentPtr whichDocument);
- void MyRepaginateDoc(MyDocumentPtr whichDocument);
- OSErr MyReplaceCollectionItem(void *newData, long collectSize,
- OSType collectType, long collectID,
- Collection whichCollection,
- Ptr *oldData, long *oldDataSize);
-
- // resource & menu item equates:
-
- #define rMenuBar 128
- #define mApple 128
- #define iAbout 1
-
- #define mFile 129
- #define iNew 1
- #define iOpen 2
- #define iClose 3
- #define iSave 4
- #define iSaveAs 5
- #define iPageSetup 7
- #define iCustomPageSetup 8
- #define iPrint 9
- #define iPrintOneCopy 10
- #define iQuit 12
-
- #define mEdit 130
- #define iUndo 1
- #define iCut 3
- #define iCopy 4
- #define iPaste 5
- #define iClear 6
-
- #define mDocument 131
- #define iInsertPage 1
- #define iDeletePage 2
- #define iAheadPage 4
- #define iBackPage 5
-
-
-
-